﻿
using CPPEI.Coolzon.Service.UpdateService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UpdateServer
{
    /// <summary>
    /// 更新服务
    /// </summary>
    [ServiceContract]
    public interface IUpdateService
    {
        /// <summary>
        /// 根据本地的版本信息获取跟新计划
        /// </summary>
        /// <param name="localVersion"></param>
        /// <returns></returns>
        [OperationContract]
        UpdateSchedule GetUpdateSchedule(string product, string appType, string appVersion);

        /// <summary>
        /// 根据计划版本更新文件
        /// </summary>
        /// <param name="appType"></param>
        /// <param name="scheduleMode"></param>
        /// <param name="scheduleVersion"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        [OperationContract]
        UpdateResult UpdateFile(string product, string appType, string scheduleMode, string formVersion, string scheduleVersion, string filePath);

        /// <summary>
        /// 上传文件片段,这是曾量的包上传
        /// </summary>
        /// <param name="product"></param>
        /// <param name="appType"></param>
        /// <param name="fromVersion"></param>
        /// <param name="toVersion"></param>
        /// <param name="start"></param>
        /// <param name="length"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        [OperationContract]
        UploadResult UploadIncrementalPatchFileSegment(string product,
            string appType, 
            string fromVersion,
            string toVersion,
            long start,
            int length,
            byte[] data);

        /// <summary>
        /// 上传完整包文件片段
        /// </summary>
        /// <param name="product"></param>
        /// <param name="appType"></param>
        /// <param name="toVersion"></param>
        /// <param name="start"></param>
        /// <param name="length"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        [OperationContract]
        UploadResult UploadFullPatchFileSegment(string product,
            string appType,
            string toVersion,
            long start,
            int length,
            byte[] data);

        /// <summary>
        /// 更新产品的版本信息
        /// </summary>
        /// <param name="product"></param>
        /// <param name="appType"></param>
        /// <param name="version"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        [OperationContract]
        UpdateVersionResult UpdateVersion(string product, string appType, string version, bool isNecessary);

        /// <summary>
        /// 获取补丁信息
        /// </summary>
        /// <param name="product"></param>
        /// <param name="appType"></param>
        /// <param name="localVersion"></param>
        /// <param name="patchType"></param>
        /// <returns></returns>
        [OperationContract]
        PatchInfo GetPackage(string product, string appType, string localVersion, PatchType patchType);

        /// <summary>
        /// 检查版本信息
        /// </summary>
        /// <param name="product"></param>
        /// <param name="appType"></param>
        /// <param name="localVersion"></param>
        /// <returns></returns>
        [OperationContract]
        CheckVersionResult CheckVersion(string product, string appType, string localVersion);

        /// <summary>
        /// 下载增量包
        /// </summary>
        /// <param name="product"></param>
        /// <param name="appType"></param>
        /// <param name="fromVersion"></param>
        /// <param name="toVersion"></param>
        /// <param name="start"></param>
        /// <returns></returns>
        [OperationContract]
        DownloadResult DownloadIncrementalPatchFileSegment(string product,
            string appType,
            string fromVersion,
            string toVersion,
            long start);

        [OperationContract]
        DownloadResult DownloadFullPatchFileSegment(string product,
            string appType,
            string toVersion,
            long start);
    }
}
